package org.example;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import java.util.Scanner;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileSystem;
import java.net.URI;
public class InvertedRunner {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        //创建配置文件
        Configuration conf = new Configuration();
        //获取一个作业
        Job job = Job.getInstance(conf);

        //设置整个job所用的那些类在哪个jar包
        job.setJarByClass(InvertedRunner.class);

        //本job使用的mapper、combiner和reducer的类
        job.setMapperClass(InvertedMapper.class);
        job.setReducerClass(InvertedReducer.class);
        job.setCombinerClass(InvertedCombiner.class);

        //指定reduce的输出数据key-value类型
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(Text.class);


        //指定mapper的输出数据key-value类型
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(Text.class);

        //指定要处理的输入数据存放路径
        FileInputFormat.setInputPaths(job, new Path("C:\\ij data\\Inverted\\data"));

        //指定处理结果的输出数据存放路径
        FileOutputFormat.setOutputPath(job,new Path("C:\\ij data\\Inverted\\src\\target"));

        //将job提交给集群运行
        boolean res=job.waitForCompletion(true);
        System.exit(res ? 0 : 1);
    }


}
